package fields;

import view.Boundary;
import model.Player;

public abstract class Field {
	private int number;
	private String name;

	public Field(int number, String name) {
		this.number = number;
		while (name.contains("  ")){
			name = name.replace("  ", " ");
		}
		this.name = name.trim();
		Boundary.setTitleText(number, this.name);
		Boundary.setSubText(number, this.name);
		Boundary.setDescriptionText(number, this.name.replace("-<br>", ""));
	}

	public abstract void landOnField(Player player);

	public int getNumber() {
		return this.number;
	}

	public String getName() {
		return this.name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + this.number;
		return result;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other) return true;
		if (other == null) return false;
		if (!(other instanceof Field)) return false;
		Field o = (Field) other;
		return this.number == o.number;
	}

	@Override
	public String toString() {
		return "Field [number=" + this.number + ", name=" + this.name + "]";
	}	
}